package org.zhq.frames;

import org.zhq.core.IoArgs;

import java.io.IOException;
import java.nio.channels.WritableByteChannel;

/**
 * @author zhengquan
 * @date 2019/2/9
 */
public class ReceiveEntityFrame extends AbsReceiveFrame{

    private WritableByteChannel channel;

    ReceiveEntityFrame(byte[] header) {
        super(header);
    }

    public void bindPacketChannel(WritableByteChannel channel){
        this.channel = channel;
    }

    @Override
    protected int consumeBody(IoArgs args) throws IOException {
        return channel==null?args.setEmpty(bodyRemaining):args.writeTo(channel);
    }
}
